package menu;

import java.util.ArrayList;
import menu.ItemInterface.TransItem;
import saves.EntidadeNave;
import saves.SaveManager;
import screen.Dialog;

/**
 *
 * @author Luan
 */
public class TalkInterface implements Menu {

    private Dialog dialog;
    private EntidadeNave player, npc;
    private Menu parent;
    
    public TalkInterface(EntidadeNave player, EntidadeNave npc) {
        this.player = player;
        this.npc = npc;
        this.dialog = new Dialog(500, "Choose what you'd like to do:", new String[] {"Buy", "Sell", "Trade", "View proposal"});
        
        this.parent = null;
    }
    
    @Override
    public void draw() {
        dialog.desenhar();
    }

    @Override
    public Menu go() {
        switch (dialog.getSelectedItem()) {
            case 0: return new ItemInterface(player, npc, 1);
            case 1: return new ItemInterface(player, npc, 2);
            case 2: return new ItemInterface(player, npc, 4);
            default: {
                ArrayList<TransItem> list = new ArrayList<>();
                list.add(new TransItem(player.getInventory().getItems().get(0).getItem(), 1, false));
                list.add(new TransItem(player.getInventory().getItems().get(1).getItem(), 1, false));
                return new ItemInterface(player, npc, list, 75);
            }
        }
    }

    @Override
    public Menu back() {
        return null;
    }

    @Override
    public int getActionCode() {
        return -1;
    }

    @Override
    public void parse(int code, char c) {
        dialog.parse(code, c);
    }

    @Override
    public Menu setProfile(SaveManager.Profile save) {
        this.player = save.getSave().getPlayer();
        return this;
    }

    @Override
    public Menu getParent() {
        return parent;
    }

    @Override
    public void setParent(Menu m) {
        this.parent = m;
    }

    @Override
    public void dispose() { }

    @Override
    public Menu zerar() {
        return this;
    }    
}
